Repository navigation
arch/arm/stm32: fix the SPI issues found in the review of #22493 - #22721
Open
raiden00pl wants to merge 4 commits into
Open
raiden00pl wants to merge 4 commits into
raiden00pl wants to merge 4 commits into
Conversation
The word size was taken from CFG1.CRCSIZE, which never changes, so 16-bit frames used 8-bit DMA. The RX queue indexes were in bytes but used as DMA transfer counts and as word counts for SPIS_DEV_RECEIVE. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <raiden00@railab.me>
…ueue. spi_enqueue() disabled the SPI to arm the TX DMA even while NSS was low, cutting the current frame. Arm the TX DMA only while NSS is high, else from the NSS rising edge, as SPIS_CTRLR_ENQUEUE requires. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <raiden00@railab.me>
A transfer larger than SPIn_DMA_BUFFER was cut to the buffer size and the rest was dropped without error. Fall back to non-DMA, as SPI v3. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <raiden00@railab.me>
STM32_SPI_CLK_MAX was 200 MHz, which is the kernel clock limit, not the SCK limit. DS14359 gives 133 MHz as the master mode maximum. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <raiden00@railab.me>
raiden00pl
requested review from
hartmannathan,
jerpelea and
xiaoxiang781216
as code owners
December 2, 2026 09:01
GUIDINGLI
approved these changes
Dec 2, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes for the issues raised in the review of #22493:
CFG1.CRCSIZE, which never changes, so 16-bit frames used 8-bit DMA. The
RX queue indexes were in bytes but used as DMA transfer counts and as word
counts for SPIS_DEV_RECEIVE (RX DMA wrote 2 x QSIZE bytes into the queue).
NSS was low, cutting the current frame. The TX DMA is now armed only
while NSS is high, else from the NSS rising edge, as SPIS_CTRLR_ENQUEUE
requires.
size and the rest was dropped without error. It now falls back to
non-DMA, as SPI v3 does.
gives 133 MHz as the master SCK maximum.
Impact
STM32 SPI slave on H7 (9-16 bit mode, TX enqueue), SPI v1v2 with
SPIn_DMA_BUFFER (F1/F2/F3/F4/G4/L1/F7/L4/L5/WB/WL5), H7R/S SPI clock limit.
No API or Kconfig change.
Testing
SPI v1v2 DMA buffer (NUCLEO-L496ZG + X-NUCLEO-EEPRMA1)
SPI1 DMA with SPI1_DMA_BUFFER=16. 256 random bytes written to each EEPROM
with
dd bs=256, read back withdd bs=256anddd bs=8, compared on thehost.
Before:
After:
SPI v3 slave (NUCLEO-H743ZI slave, NUCLEO-F446RE master)
SPI1 slave (/dev/spislv1,
spislv), SPI1 master on the F446RE (spi).16-bit frames (SPI_SLAVE_DRIVER_WIDTH=16), before:
After:
Enqueue while the master holds NSS low (F446RE PB6 driven low with
mw),H743 SPI1 CFG1 read over SWD. Before, TXDMAEN (bit 15) is set while NSS is
low, so the SPI was disabled during the frame:
After, the TX DMA is armed on the NSS rising edge:
8-bit transfers pass as before:
Not tested on hardware: the H7R/S SPI clock limit (build only).